<template>
  <div>
    <!-- 相关新闻 -->
    <div class="bg-ff padding-lr20">
      <div
        class="flex news_li border-bottom padding-20"
        v-for="(item, index) in article"
        :key="index"
        @click="to('/recruit/news',item.article_id)"
      >
        <img class="margin-r24" v-if="item.thumb" :src="item.thumb" alt />
        <img class="margin-r24" v-if="!item.thumb" src="@/assets/img/nodata.png" alt />
        <div class="flex-grow">
          <div class="rem-32px text-cut-two text-content">{{item.article_title}}</div>
          <div class="flex justify-between news_li_s">
            <div class="rem-20px c-66 news_li_tip">{{item.enterprise_title}}</div>
            <div class="rem-20px c-66">{{item.created_at.slice(0, 10)}}</div>
          </div>
        </div>
      </div>
    </div>

    <load @loadData="getArticle" :list="article" :total="total" :nodata="article.length <= 9 ? true : false"></load>
  </div>
</template>

<script>
import load from "../../components/load";
export default {
  components: {
    load
  },
  data() {
    return {
      article: [],
      id: this.$route.query.id,
      total: 0
    };
  },
  mounted() {
    this.getArticle(1);
  },
  methods: {
    // 资讯新闻 申请记录 浏览记录
    getArticle(page) {
      let ajaxurl = "/wap/info/article";
      this.$axios.post( ajaxurl, {
        enterprise_id: this.id,
        page: page,
        limit: 10
      }).then(res => {
        if (page == 1) {
          this.list = [];
          this.topList = [];
        }
        if (res.data.data.length == 0) {
          this.total++;
          return false;
        }
        for (let i in res.data.data) {
          this.article.push(res.data.data[i]);
        }
      });
    },
    to(path,id){
      this.$router.push({
        path: path,
        query: {
          id: id
        }
      })
    }
  }
};
</script>

<style scoped>
/* 最新资讯 */
.news_li:last-of-type {
  border-bottom: none;
}

.news_li img {
  min-width: 2.27rem;
  max-width: 2.27rem;
  height: 1.72rem;
  object-fit: contain;
}

.news_li_s {
  margin-top: 0.1rem;
  height: 0.42rem;
  line-height: 0.42rem;
}

.news_li_tip {
  padding: 0 0.12rem;
  background: #f2f2f2;
  border-radius: 0.05rem;
}
</style>